using System.Security.Cryptography;
using System.Text;

namespace TheBoard.Models
{
    public class GravatarService : IGravatarService
    {
        public string GetImageUrl(string email)
        {
            using (var md5 = new MD5CryptoServiceProvider())
            {
                var bytes = Encoding.UTF8.GetBytes((email ?? "").Trim().ToLower());
                return "http://www.gravatar.com/avatar/" + HexConvert.Encode(md5.ComputeHash(bytes, 0, bytes.Length));
            }
        }
    }
}